package cn.mysdp.biz.controller;


import cn.mysdp.biz.controller.*;
import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: SdpSqlWebController
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_sql
 * Comment:
 * 
 */
@RestController
@RequestMapping(value = "/sdp_sql")
public class SdpSqlWebController extends SdpSqlWebCustomController {
    static {
        addRequestClass("sdp_sql", "add", "sdpSqlController", SdpSqlWebController.class, SdpSqlAddRequest.class);
        addRequestClass("sdp_sql", "add_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlAddRequest.class);

        addRequestClass("sdp_sql", "update", "sdpSqlController", SdpSqlWebController.class, SdpSqlUpdateRequest.class);
        addRequestClass("sdp_sql", "update_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlUpdateRequest.class);

        addRequestClass("sdp_sql", "delete", "sdpSqlController", SdpSqlWebController.class, SdpSqlDeleteRequest.class);
        addRequestClass("sdp_sql", "delete_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlDeleteRequest.class);

        addRequestClass("sdp_sql", "query", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);
        addRequestClass("sdp_sql", "query_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);

        addRequestClass("sdp_sql", "list", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);
        addRequestClass("sdp_sql", "list_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);

        addRequestClass("sdp_sql", "count", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);
        addRequestClass("sdp_sql", "count_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);

        addRequestClass("sdp_sql", "stat", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);
        addRequestClass("sdp_sql", "stat_encrypt", "sdpSqlController", SdpSqlWebController.class, SdpSqlQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addSdpSql(@RequestBody SdpSqlAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_sql", "add", request, callFromEncrypt);
        return super.addSdpSql(request);
    }

    @PostMapping("/add_encrypt")
    public String addSdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlAddRequest request = (SdpSqlAddRequest) super.decrypt("sdp_sql", "add_encrypt", strRequest, SdpSqlAddRequest.class);
        Integer result = addSdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateSdpSql(@RequestBody SdpSqlUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_sql", "update", request, callFromEncrypt);
        return super.updateSdpSql(request);
    }

    @PostMapping("/update_encrypt")
    public String updateSdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlUpdateRequest request = (SdpSqlUpdateRequest) super.decrypt("sdp_sql", "update_encrypt", strRequest, SdpSqlUpdateRequest.class);
        Integer result = updateSdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteSdpSql(@RequestBody SdpSqlDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_sql", "delete", request, callFromEncrypt);
        return super.deleteSdpSql(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteSdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlDeleteRequest request = (SdpSqlDeleteRequest) super.decrypt("sdp_sql", "delete_encrypt", strRequest, SdpSqlDeleteRequest.class);
        Integer result = deleteSdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public SdpSqlQueryResponse querySdpSql(@RequestBody SdpSqlQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("sdp_sql", "query", request, callFromEncrypt);
      SdpSqlQueryResponse result = super.querySdpSql(request);
      super.fixResult("sdp_sql", "query", request);
      return result;
    }

    @PostMapping("/query_encrypt")
    public String querySdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlQueryRequest request = (SdpSqlQueryRequest) super.decrypt("sdp_sql", "query_encrypt", strRequest, SdpSqlQueryRequest.class);
        SdpSqlQueryResponse result = querySdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<SdpSqlQueryResponse> listSdpSql(@RequestBody SdpSqlQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_sql", "list", request, callFromEncrypt);
        List<SdpSqlQueryResponse> list = super.listSdpSql(request);
        super.fixResult("sdp_sql", "list", list);
        return list;
    }

    @PostMapping("/list_encrypt")
    public String listSdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlQueryRequest request = (SdpSqlQueryRequest) super.decrypt("sdp_sql", "list_encrypt", strRequest, SdpSqlQueryRequest.class);
        List<SdpSqlQueryResponse> result = listSdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countSdpSql(@RequestBody SdpSqlQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("sdp_sql", "count", request, callFromEncrypt);
      return super.countSdpSql(request);
    }


    @PostMapping("/count_encrypt")
    public String countSdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlQueryRequest request = (SdpSqlQueryRequest) super.decrypt("sdp_sql", "count_encrypt", strRequest, SdpSqlQueryRequest.class);
        Integer result = countSdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statSdpSql(@RequestBody SdpSqlQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_sql", "stat", request, callFromEncrypt);
        return super.statSdpSql(request);
    }

    @PostMapping("/stat_encrypt")
    public String statSdpSqlEncrypt(@RequestBody String strRequest) throws Exception {
        SdpSqlQueryRequest request = (SdpSqlQueryRequest) super.decrypt("sdp_sql", "stat_encrypt", strRequest, SdpSqlQueryRequest.class);
        BaseStatResponse result = statSdpSql(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


    static {
        addRequestClass("sdp_sql", "clone", "sdpSqlController", SdpSqlWebController.class, BaseNameIdRequest.class);
        addRequestClass("sdp_sql", "clone_encrypt", "sdpSqlController", SdpSqlWebController.class, BaseNameIdRequest.class);
    }
    
    @ResponseBody
    @PostMapping("/clone")
    public Integer clone(@RequestBody BaseNameIdRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_sql", "clone", request, callFromEncrypt);
        Integer result = super.clone(request);
        super.fixResult("sdp_sql", "clone", request);
        return result;
    }

    @ResponseBody
    @PostMapping("/clone_encrypt")
    public String cloneEncrypt(@RequestBody String strRequest) throws Exception {
        BaseNameIdRequest request = (BaseNameIdRequest)decrypt("sdp_sql", "clone_encrypt", strRequest, BaseNameIdRequest.class);
        Integer result = clone(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

}
